package day16;
//测试守护线程
public class Protect implements Runnable{

    public void run() {
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("章鱼大帅哥！");
        }
    }
}

class User implements Runnable{
    public void run() {
        for (int i=0;i<10;i++){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("章鱼大帅哥更帅了！");
        }
    }

    public static void main(String[] args) {
        Protect pro=new Protect();
        User user=new User();
        Thread t1=new Thread(pro);
        //设置守护线程  切记：不能在线程开启之后设置
        t1.setDaemon(true);
        Thread t2=new Thread(user);
        t1.start();
        t2.start();
    }
}